<?php
require_once "includes/database.php";

class Lop extends database {
	private $maLop;
	private $tenLop;
	private $maKhoaHoc;
	private $danhSachSinhVien;
	
	public function __construct($maLop = "", $tenLop = "", $maKhoaHoc = "") {
		parent::__construct();
		$this->maLop = $maLop;
		$this->tenLop = $tenLop;
		$this->maKhoaHoc = $maKhoaHoc;
	}
	
	public function getMaLop() { return $this->maLop; }
	public function getTenLop() { return $this->tenLop; }
	public function getMaKhoaHoc() { return $this->maKhoaHoc; }
	
	public function layThongTinLop() {
		$result = $this->select("LOP", array("LOP_MA_SO", "LOP_TEN", "KH_MA_SO"),
								"LOP_MA_SO = '" . $this->maLop . "'");
		if ($row = mysql_fetch_assoc($result)) {
			$this->tenLop = $row['LOP_TEN'];
			$this->maKhoaHoc = $row['KH_MA_SO'];
			$this->taoDanhSachSinhVien();
			return true;
		} else return false;
	}
	
	private function taoDanhSachSinhVien() {
		$result = $this->select("SINH_VIEN", array("SV_MA_SO", "concat(SV_HO, ' ', SV_TEN) as SV_HO_TEN"),
								"LOP_MA_SO = '" . $this->maLop . "' ORDER BY SV_MA_SO");
		$this->danhSachSinhVien = array();
		
		while ($row = mysql_fetch_assoc($result))
			$this->danhSachSinhVien[] = $row;
	}
	
	public function getDanhSachSinhVien() { return $this->danhSachSinhVien; }
}

?>